 const reqInterface = require('../../../api/models')
 Page({

   data: {
     info: {
       username: '',
       phone: '',
       password: '',
       comfirm_password: '',
       role: 0 ,// 1物业 2其他
       car_number: ''
     },
     roleList: [{
       id: 1,
       name: '物业'
     }, {
       id: 2,
       name: '业主'
     }]
   },

   sumbit() {
     let self = this;

     reqInterface.PostRegister(self.data.info).then(res => {
       wx.showModal({
         title: '注册成功',
         content: '前往登录',
         showCancel: false,
         complete: (res) => {
           if (res.confirm) {
             wx.navigateTo({
               url: '/pages/login/index/index',
             })
           }
         }
       })
     })
   },

   usernameValue(e) {
     let self = this;
     self.setData({
       'info.username': e.detail.val
     })
   },
   phoneValue(e) {
    //  这里手机号可以做验证正则，但是到时候演示没那么多时间试错的，就不验证了 就输入一个符合正则的手机号就行
     let self = this;
     self.setData({
       'info.phone': e.detail.val
     })
   },
   passwordValue(e) {
     let self = this;
     self.setData({
       'info.password': e.detail.val
     })
   },
   comfirmPasswordValue(e) {
     let self = this;
     self.setData({
       'info.comfirm_password': e.detail.val
     })
   },
   roleValue(e) {
     let self = this;
     self.setData({
       'info.role': e.detail.val
     })
   },
   carNumberValue(e) {
    let self = this;
    self.setData({
      'info.car_number': e.detail.val
    })
  },
 })